package com.foreknow.demo6;

/**
 * Swallow为子类
 * Bird为父类(超类)
 * 问题：为什么使用继承？Java中的继承是为解决可重用
 */
public class Swallow extends Bird {

    public void fly() {
        System.out.println(getName() + "正在飞");
    }

    public static void main(String[] args) {
        Bird bird = new Bird();
        bird.setName("鸟");
        bird.setColor("白");
        bird.eat();
        System.out.println("------------------------------");
        Swallow swallow = new Swallow();
        swallow.setName("燕子");
        swallow.setColor("黑");
        swallow.eat();
        swallow.fly();
    }
}
